﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using DBUtility;
using IDAL.RF.Package;
using Model.RF.Package;

namespace DAL.RF.Package
{
    public class PackintoBoxItem : BaseRepository_DT<PackintoBoxItemInfo>, IPackintoBoxItem
    {
        #region 静态变量部分
        private const string PARM_PACKINTOBOXITEM_PACKAGEPRODUCTSN = "@PackageProductSN";
        private const string PARM_PACKINTOBOXITEM_ID = "@ID";
        #endregion

        #region 数据检索部分
        public IList<PackintoBoxItemInfo> GetPackintoBoxItem_bySN(string packageProductSN)
        {
            SqlParameter parm = GetParameter();
            parm.Value = packageProductSN;
            return ExcuteSqlToGetEntities("PackintoBoxItem_GetbySN", parm);
        }

        public IList<PackintoBoxItemInfo> GetPackintoBoxItem_byID(int ID)
        {
            SqlParameter parm = GetIDParameter();
            parm.Value = ID;
            return ExcuteSqlToGetEntities("PackintoBoxItem_GetbyID", parm);
        }
        #endregion


        #region 重写基类部分
        //-------------------------------------重写超类基础操作---------------------------------------------------------

        public override PackintoBoxItemInfo GetEntityRecord(SqlDataReader rdr)
        {
            PackintoBoxItemInfo pro = new PackintoBoxItemInfo()
            {
                ID=rdr.GetInt32(0),
                PackageProductSN = rdr.GetValue(1).ToString(),
                RecordTime = rdr.GetDateTime(2),
                ProductTypeID = rdr.GetValue(3).ToString(),
                UserID = rdr.GetValue(4).ToString(),
                IsUnpack=rdr.GetBoolean(5)
            };
            return pro;
        }

        public override PackintoBoxItemInfo GetEntityRecord()
        {
            PackintoBoxItemInfo pro = null;
            return pro;
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter Parm = new SqlParameter(PARM_PACKINTOBOXITEM_PACKAGEPRODUCTSN, SqlDbType.NVarChar, 50);
            return Parm;
        }

        public SqlParameter GetIDParameter()
        {
            SqlParameter Parm = new SqlParameter(PARM_PACKINTOBOXITEM_ID, SqlDbType.Int, 4);
            return Parm;
        }
        #endregion
    }
}
